﻿@using BusinessBingo.Web.Models.ViewModels;
@model BusinessBingo.Web.Models.ViewModels.BoxedBingoSetViewModel

@using (Html.BeginForm("CheckWord", "Game", FormMethod.Post, new { id = "bingoSetForm" }))
{
	int columnWidth = Model.BoxSize / Model.BingoSetViewModel.Size;
    int wordRendered = 0;
    
	for (int row = 0; row < Model.BingoSetWordsInRow.Count; row++)
	{
        <text><div class="box-@Model.BoxSize"></text> 
        
        for (int word = 0; word < Model.BingoSetWordsInRow[row].Count; word++)
        {
            var wordPositionViewModel = Model.BingoSetWordsInRow[row][word];

            string contextCss = "";

            if (word == 0)
            { 
                contextCss = "no-margin-left";
            }

            if ((word + 1) == Model.BingoSetWordsInRow[row].Count)
            { 
                contextCss = "no-margin-right";
            }
            
            <div class="box-@columnWidth @contextCss">
			@if (wordPositionViewModel.Checked == false && Model.BingoSetViewModel.Finished == false)
			{ 
				<a href="javascript:CheckWord('@wordPositionViewModel.WordId');">
					<p class="normalBox">
						@wordPositionViewModel.WordName
					</p>
				</a>
			}
			else
			{
					<p class="normalBox highlightedBox">
						@wordPositionViewModel.WordName
					</p>
			}

			@* Used for creating a instant bingoset *@
			<input type="hidden" name="BingoSet.WordPositions[@wordRendered].Word.Id" value="@wordPositionViewModel.WordId" />
			<input type="hidden" name="BingoSet.WordPositions[@wordRendered].PositionX" value="@wordPositionViewModel.PositionX" />
			<input type="hidden" name="BingoSet.WordPositions[@wordRendered].PositionY" value="@wordPositionViewModel.PositionY" />

            @{ wordRendered++; }

		    </div>
        }
	
        @Html.Raw("</div>");


}
	<input type="hidden" id="clickedWordId" name="ClickedWordId" />
}
